﻿using System.Text;
using System.Web.Mvc;

namespace Mvc3Demo.Controllers
{
    public class CacheController : Controller
    {
        public string Index()
        {
            Response.ContentType = "text/cache-manifest";
            var result = new StringBuilder();
            result.AppendLine("CACHE MANIFEST");
            result.AppendLine("# Version 0.1");
            result.AppendLine("CACHE:");
            result.AppendLine(Url.Action("Index", "Home"));

            var staticResources = new[]
                                  {
                                      "~/Content/Site.css",
                                      "~/Content/themes/base/jquery.ui.all.css",
                                      "~/Content/jquery.mobile-1.0b3.min.css",
                                      "~/Content/Mobile/Mobile.css",
                                      "~/Scripts/jquery-1.6.4.min.js",
                                      "~/Scripts/jquery-ui-1.8.11.js",
                                      "~/Scripts/modernizr-2.0.6-development-only.js",
                                      "~/Scripts/AjaxLogin.js",
                                      "~/Scripts/jquery-1.6.3.min.js",
                                      "~/Scripts/jquery.mobile-1.0b3.min.js",
                                      "~/Scripts/jquery.validate.min.js",
                                      "~/Scripts/jquery.validate.unobtrusive.min.js"
                                  };
            foreach (var staticResource in staticResources)
            {
                result.AppendLine(Url.Content(staticResource));
            }

            result.AppendLine("FALLBACK:");
            result.AppendLine("/status /offline");
            result.AppendLine("NETWORK:");
            result.AppendLine("*");

            return result.ToString();
        }

    }
}
